/**
 * This file is part of Wireless TransFer.
 *
 *   Wireless TransFer is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *	
 *   Wireless TransFer is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with Wireless TransFer.  If not, see <http://www.gnu.org/licenses/>.
 *
 *   @author prebz
 */

package com.wirelesstransfer.server.WIFI.handlers;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import com.wirelesstransfer.server.Ifiles;

public class Files implements Ifiles{
		
	private List<File> addedFiles;
	
	public Files(){
		addedFiles = new ArrayList<File>();
	}
	
	
	/**
	 * check if file is in the list
	 * @param file
	 * @return true if present
	 */
	public boolean isInList(File file){
		return addedFiles.contains(file);
	}

	/**
	 * add file to list
	 * @param file
	 * @return true if added
	 */
	public boolean addFile(File file) {
		addedFiles.add(file);
		return true;
	}
	

	/**
	 * remove file to list
	 * @param file
	 * @return true if removed
	 */
	public boolean removeFile(File file) {
			addedFiles.remove(file);
			return true;
	}

	/** 
	 * returns a list of all files
	 */
	public List<File> getFiles() {
		return addedFiles;
	}
	
	/**
	 * clears the list of files
	 */
	public void clearFiles(){
		addedFiles.clear();
	}
	
	/**
	 * Prints all added files
	 * @param addedFiles
	 */
	@Override
	public String toString(){
		String files = "";
		int count = 0;
		for (File added : addedFiles)
			if (count >= addedFiles.size()-1) {
				files += added.getAbsolutePath() + "<" + added.length();
			} else {
				files += added.getAbsolutePath() + "<" + added.length() + ":";
			}
			count++;
		return files;
	}



}
